﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors.DXErrorProvider;

namespace ChinaDynastyTours.Views
{
    public partial class PaymentMethodForm : DevExpress.XtraEditors.XtraForm
    {
        public PaymentMethodForm()
        {
            InitializeComponent();
        
            InitValidationRules();
        }
        /// <summary>
        /// 控件数据校验
        /// </summary>
        private void InitValidationRules()
        {
            ConditionValidationRule notEmptyValidationRule = new ConditionValidationRule();
            notEmptyValidationRule.ConditionOperator = ConditionOperator.IsNotBlank;
            notEmptyValidationRule.ErrorText = "不能为空";

            //不能为空
            dxValidationProvider.SetValidationRule(tbRemark, notEmptyValidationRule);
        }


        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider.Validate())  return;
            if (MessageBox.Show("确认付款吗？此操作不可逆！", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                DialogResult = DialogResult.OK;
        }

        private void bigClassGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (bigClassGroup.SelectedIndex)
            {
                case 0://支付
                    payGroup.Enabled = true;
                    //tbRemark.Enabled = true;
                    break;
                case 1://支票预付
                    payGroup.Enabled = false;
                    //tbRemark.Enabled = false;
                    break;
                case 2://月结
                    tbRemark.Enabled = false;
                    //payGroup.Enabled = false;
                    break;
                default: break;
            }
        }
    }
}
